<style>
 span.publish {
    background-image: url("/images/admin/tick.png");
}
span.state {
    display: inline-block;
    height: 16px;
    width: 16px;
}
</style>
<script language="javascript">
   $(document).ready(function() {
    $('#Usertable').dataTable( {
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
     "aaSorting": [[ 0, "desc" ]]
    } );
} );

</script>
<?php
if($this->stat == "added")
{
?>
	<div id="success_msg">User successfully saved</div>
<?php
} else if ($this->stat == "updated") {
?>
	<div id="success_msg">User successfully updated</div>
<?php
} else if ($this->stat == "deleted") {
?>
	<div id="success_msg">User successfully deleted</div>
<?php
}
?>
<?php
echo $this->adminToolBar('User', 'index', '/admin/User/add/', '/admin/User/edit/', '/admin/User/delete/', '');
?>

<div>
    
          <table id="Usertable" align="center" width="100%" cellspacing="2" cellpadding="2" bordercolor="#e0e0e0" border="0" style="border:solid 1px #e0e0e0; border-radius:5px;margin-left: 20px;border-right-width: 1px;width: 1323px;margin-top: 20px;margin-bottom: 20px; ">
              <thead>
                  <tr>
                 
                  <td>First Name</td>
                  <td>Last Name</td>
                  <td>Email</td>
                  <td>Username</td>
                  <td>User Type</td>
                  <td>status</td>
                  
                  <td>&nbsp;</td>
                  </tr>

              </thead>
              
              <tbody>

              <?php foreach($this->Userarr as $Userarr):

                      if($Userarr['admin_status'] == 1)
			{
				$status = "<img src='/images/admin/publish.png' title='unpublish' />";
			} else {
				$status = "<img src='/images/admin/publish_x.png' title='publish' />";
			}	


                      ?>
            <tr>
                
                  <td><a href="/admin/User/edit/admin_id/<?php echo $Userarr["admin_id"] ?>"><?php echo $Userarr["admin_firstname"] ?></a></td>
                   <td><a href="/admin/User/edit/admin_id/<?php echo $Userarr["admin_id"] ?>"><?php echo $Userarr["admin_lastname"] ?></a></td>
                  <td><?php echo $Userarr["admin_email"] ?></td>
                  <td><?php echo $Userarr["admin_username"] ?></td>
                  <td><?php echo $Userarr["admin_userType"] ?></td>
                 
                  <td><a href="javascript: void(0);" onclick="changeUserStatus('<?php echo $Userarr['admin_id']; ?>')"><?php echo $status; ?></a></td>
        
                  <td><a href="javascript: void(0);" onclick="deleteNews('<?php echo $Userarr['admin_id']; ?>')"><img src="/images/admin/icons/delete.gif" width="18" height="18" /></a></td>
             </tr>
      
           <?php endforeach;?>
          </tbody>
          </table>

      </div>

<script language="javascript">

        function deleteNews(admin_id)
        {
            if(confirm("Are you sure that you want to delete this post?"))
                {
                     location.href="/admin/User/delete/admin_id/"+admin_id;
                }
                else{
                    return false;
                }
           
            
        }

        function changeUserStatus(admin_id)
{
	$("#loader").show();
	$("#loader").html("<img src='/images/loader.gif' /> loading...");

	$.ajax({
        type: "POST",
        data: ({admin_id: admin_id}),
        url: "/admin/User/changestatus/",
        success: function(data){
            $("#loader").hide();
            window.location.reload();
        }
    });
}

 </script>